package com.cmy.lesson05;

import com.cmy.lesson05.utils.JdbcUtils_C3P0;


import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class TestC3p0 {
    public static void main(String[] args) {
        Connection conn = null;
        Statement st = null;
        ResultSet rs = null;
        try {
            conn = JdbcUtils_C3P0.getConnection();//通过dbcp数据源获取数据库连接
            st = conn.createStatement();//获得sql的执行对象
            String sql = "INSERT INTO `users`(`id`,`NAME`,`PASSWORD`,`email`,`birthday`)" +
                    "VALUES(4,'void','3492611','2603135842@qq.com','1999-01-01')";
            int i =st.executeUpdate(sql);
            if (i>0){
                System.out.println("插入成功");
            }
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }finally {
            JdbcUtils_C3P0.release(conn,st,rs);
        }
    }
}

    